import 'package:flutter/material.dart';
import '../model/details.dart';
import '../service/service_method.dart';
import 'dart:convert';

class DetailsInfoProvide with ChangeNotifier{
  DetailsModel goodsinfo=null;
  bool isLeft=true;
  bool isRight=false;

  //tabbar的切换方法
  changeLeftAndRight(String changestate){
    if(changestate=='left'){
      isLeft=true;
      isRight=false;
    }else{
       isLeft=false;
      isRight=true;
    }
      notifyListeners();
  }


  //从后台获取商品数据
  getGoodsInfo(String id) async{
    var formData={'goodId':id};
   await request('getGoodDetailById',formData:formData).then((val){
      var responseData=json.decode(val.toString());
      print(responseData);
      goodsinfo=DetailsModel.fromJson(responseData);
      notifyListeners();
    });
  }

}